home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10877 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: avalon.net!news
  2. From: craiger@avalon.net     [Craig Miller]
  3. Newsgroups: comp.lang.c
  4. Subject: Re: given: char foo[80]; there is no such thing as element foo[80] correct? (i.e. foo[80] = '\0' is beyond the array boundary)
  5. Date: 20 Mar 1996 16:37:41 GMT
  6. Organization: Avalon Networks Inc.
  7. Message-ID: <4ipc8l$t3g@arthur.avalon.net>
  8. References: <3148DBB6.1353@hawaii.edu> <4ih0p0$7q5@vip.cybercity.dk>
  9. Reply-To: craiger@avalon.net    [Craig Miller]
  10. NNTP-Posting-Host: sioux-city-dial1.avalon.net
  11. X-Newsreader: IBM NewsReader/2 v1.2.5
  12.  
  13. In <4ih0p0$7q5@vip.cybercity.dk>, monsted@cybercity.dk (Monsted) writes:
  14.  
  15. >>Yes or no on this, I just recently got confused by two different books. I 
  16. >>assume that the declaration foo[80] allocates storage for elements 0-79. 
  17. >>A string could be terminated by doing something like foo[79] = '\0', but 
  18. >>foo[80] = '\0' would be invalid because such an element does not exist. 
  19. >>Just looking for confirmation that I'm right here. A simple Y or N will 
  20. >>do thanks.
  21.  
  22. It depends on if you mean "does foo[80] exist" or if you mean "can I write 
  23. data to foo[80]"..  foo[80] does _NOT_ exist, but you can write data to it.
  24. You will be changing the byte immediately following foo[], which could be
  25. another variable, or worse yet, program code.  Been there, done that, it's ugly.
  26.  
  27. >>-Recently confused C programmer
  28. Most of us are.  :)
  29.  
  30. Craig
  31.